package eurekaClient.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @版本号 1.0
 * @开发者: dongdq
 * @创建时间: 2021/11/1 19:55
 * @Content:
 */

@Configuration
@EnableSwagger2//开始Swagger2
public class SwaggerConfig {

    //配置了Swagger 的Docket的bean实例
    //http://127.0.0.1:9005/swagger-ui.html
    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SPRING_WEB)
                .apiInfo(apiInfo())
                .select()
                //RequestHandlerSelectors, 配置要扫描接口的方式
                //basePackage:指定要扫描的包
                //any():扫描全部
                //withClassAnnotation: 扫描类上的注解
                //withMethodAnnotation: 扫描方法上的注解
                .apis(RequestHandlerSelectors.basePackage("eurekaClient.controller"))
                .build();
    }

    //配置Swagger 信息=apiInfo
    private ApiInfo apiInfo(){

        Contact contact = new Contact("ddq","","13660676071@163.com");

        return new ApiInfo(
                "Api Documentation",
                "Dong dequan",
                "v1.0",
                "http:127.0.0.1/",
                null,//contact
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList()
                );
    }

}
